#include "Region.h"
#include "SentinelBridgeSpace.h"
#include "Space.h"

using namespace std;

namespace talisman_map
{

Region::Region() : mStartSpace(0)
{
}

// Destructor
Region::~Region()
{
	Space * wStartSpace = getStartSpace();
	if ( 0 == wStartSpace)
		return;

	Space * wIter = wStartSpace->getNextSpace();

	while (wIter != wStartSpace)
	{
		Space * wNextSpace = wIter->getNextSpace();
		wIter->resetReferences();
		delete wIter;
		wIter = wNextSpace;
	}
}

Space * Region::getNextSpace(Space * iInitialSpace) const
{
	return iInitialSpace->getNextSpace();
}

Space * Region::getPrevSpace(Space * iInitialSpace) const
{
	return iInitialSpace->getPrevSpace();
}

}

